import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)


const routes = [
  {
    path: '/',
    name: 'about',
    redirect: "/about",
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue'),
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue'),
    redirect: "/about/index",
    children: [
      {
        path: 'index',
        name: 'index',
        components: {
          default: () => import('../views/IndexChild.vue'),
          indexclass: () => import('../views/ClassChild.vue'),
          indextags: () => import('../views/TagChild.vue'),
        }
      },
      {
        path: 'class',
        name: 'calss',
        component: () => import('../views/ClassChild.vue')
      },
      {
        path: 'tag',
        name: 'tag',
        component: () => import('../views/TagChild.vue')
      },
      {
        path: 'file',
        name: 'file',
        component: () => import('../views/FileChild.vue')
      },
      {
        path: '/article-list',
        name: 'articleList',
        components: {
          default: () => import('../views/ArticleList.vue'),
          indextags: () => import('../views/TagChild.vue'),
        }
      },
      {
        path: '/taglist',
        name: 'taglist',
        components: {
          default: () => import('../views/TagList.vue'),
          indexclass: () => import('../views/ClassChild.vue'),
        }
      },
      {
        path: '/article/:id',
        name: 'ArticleDetail',
        components: {
          default: () => import('../views/ArticleDetail.vue'),
          indexclass: () => import('../views/ClassChild.vue'),
          indextags: () => import('../views/TagChild.vue'),
        }
      },

    ]
  },
  {
    // 后台页面

    path: '/backend',
    name: 'backend',
    component: () => import('../views/BackendView.vue'),
    // redirect: "/backend/",
    children: [
      {
        // 仪表盘数据页面
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('../views/DashBoard.vue'),
      },
      {
        // 文章管理页面
        path: '/articlemanage',
        name: 'articlemanage',
        component: () => import('../views/ArticleManage.vue')
      },
      {
        // 分类管理页面
        path: '/classmanage',
        name: 'classmanage',
        component: () => import('../views/ClassManage.vue')
      },
      {
        // 标签管理页面
        path: '/tagmanage',
        name: 'tagmanage',
        component: () => import('../views/TagManage.vue')
      },
      {
        // 用户管理页面
        path: '/user',
        name: 'user',
        component: () => import('../views/UserBlog.vue')
      },
      {
        // 添加文章页面
        path: '/add',
        name: 'add',
        component: () => import('../views/ArticleAdd.vue')
        // ArticleAdd.vue
      },
      {
        // 管理标签页面
        path: '/tagsmanage',
        name: 'tagsmanage',
        component: () => import('../views/TagsManage.vue')
      },
      {
        // 用户设置页面
        path: '/setuser',
        name: 'setuser',
        component: () => import('../views/UserSet.vue')
      },

    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
